Statistical Analysis System (SAS)

105

Solutions

120

Contributors

The Statistical Analysis System (SAS) programs consist of two steps, the DATA step and the PROC step. The DATA step reads data and prepares it for use by subsequent DATA or PROC steps. A SAS procedure (PROC) is a collection of statements that execute a certain task. SAS procedures have their own statements and commands, but many are shared among procedures. JMP is the graphical user interface for SAS, and is used in applications such as Six Sigma, quality control and engineering, design of experiments and scientific research.

Share tech news, updates, or what's on your mind.

Sign up to Post

I want to be data analyst.
but i don't know, what should i learn first?

what are basic capabilities  should i have ?
0
Free Tool: Subnet Calculator
LVL 9
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I am trying to embed automatically today's date (DDMMYYD10.) and XML records counts in the XML data file header. Is there an automatic way in SAS how to do that?

This is where today's date and record counts would go:
 
put &tab2. '<SampleDate>2017-06-27</SampleDate>';
 put &tab2. '<CaseCount>10</CaseCount>';

Open in new window


Full SAS code:
filename DirectX  "&basepath\examples\XMLData2.xml";
filename Complete "&basepath\examples\XMLComplete2.xml";

libname xmldir xmlv2 xmlfileref=DirectX xmltype=generic;

/* Macro variables to provide appropriate tab spacing */
%let tab="    ";
%let tab2="        ";

/* Writing two SAS datsets to xmldir library and creating XMLData.xml data file */ 
data xmldir.class(label="dataset class from sashelp library");
       set sashelp.class(obs=10);
run;

data xmldir.cars(label="dataset cars from sashelp library");
       set sashelp.cars(obs=10); 
run; 

libname xmldir clear;

/*  XML file information and header and XML File End*/
data _null_;
 infile	DirectX end=last;
file	Complete;

input;				
 
if _N_ = 1 then
    do;  
	put _infile_;	
    put '<Schema Name="CarsAndClass">';
    put &tab. '<Header>';
    put &tab2. '<SampleDate>2017-06-27</SampleDate>';
    put &tab2. '<CaseCount>10</CaseCount>';
    put &tab2. '<Action>Initial</Action>';
    put &tab2. '<YearPeriod>2017</YearPeriod>';
    put &tab. '</Header>';
    put &tab. '<Payload>';
    end;
else
	put &tab2 _infile_;	
 
if last then
    do;
    put &tab'</Payload>';		
    put '</Schema>';
    end;    
run;

Open in new window

0
Hello,
I am trying to add a header and tabs with info about the XML data file to .xml file in SAS code. How exactly this can be done? Please see what I have currently I have for my SAS code. I can see the XML data file as my output but the Header (tab and tab2) with all info about the XML file does not show up yet in the XML file.
 
libname xmldir xmlv2 '/basepath/examples/XMLData.xml' xmltype=generic;

/* Req. 1: Macro variables to provide appropriate tab spacing. */
%let tab="    ";
%let tab2="        ";

/* Req. 2: XML file information and header*/
data _null_;
   file xmldir;
  
    put '<?xml version="1.0" encoding="UTF-8"?>';
    put '<Schema Name>';
    put &tab. '<Header>';
    put &tab2. '<SampleDate>2017-06-14</SampleDate>';
    put &tab2. '<CaseCount>30</CaseCount>';
    put &tab2. '<Action>Initial</Action>';
    put &tab2. '<YearPeriod>2017</YearPeriod>';
    put &tab. '</Header>';
    put &tab. '<Payload>';
run;

/* Req. 3: Writing two SAS datsets to xmldir library and creating XMLData.xml data file*/ 
data xmldir.dataname1(label="dataset name1 from sashelp library");
       set sashelp.dataset1(obs=10);
run;

data xmldir.dataname2(label="dataset name2 from sashelp library");
       set sashelp.dataset2(obs=20 keep=var1 var2); 
run; 

libname xmldir clear;

/* Req. 4: XML File End*/
data _null_;
   file xmldir mod;

    put &tab'<Payload>';
    put '</Schema Name>';
run;

Open in new window


So, currently only Req. 3 is working.
Any comments or suggestions will be greatly appreciated!
0
Hello everyone,
In my organization we are currently in a process transferring from using ASCII files to using XML data files when working (importing and exporting) with SAS datasets.  

So, my question is:  what would be a proper way to export multiple ( two or more) SAS datasets (dataset1, dataset2) to one XML data file (XMLData) and at the same time to make sure that XML data file actually has those multiple SAS datasets in it as tables.

The only way that I was able to export multiple SAS datasets to one  XML data file is by appending one SAS dataset to another but that's not what I want because at the end the XML data file does not have multiple tables in it - all data from multiple SAS datasets look as just one big table.  Below is working code but again it only appends multiple SAS datasets and it does not create tables in the XML data file.

libname xmldir xmlv2 '/home/profile1/xml/XMLData.xml' xmltype=generic;
libname mydir '/home/profile/sas';

data xmldir.XMLData;
       set mydir.dataset1
             mydir.dataset2; 
run; 

Open in new window


If you know how tackle this problem from any angle please let me know.  Any help would be very appreciated!
0
hi,

both SAS and IBM Cognos is analytical SW, any diff between them? I am wondering why company use both?
0
Experts,

Can someone tell me what this SAS code doing.  It appears to be a macro in a macro.
CDPS.txt
0
Experts,

I currently have my password assigned in a process that executes when SAS Enterprise Guide comes up.  I also have my libraries which require my password assigned in the same process.

This works fine for me, but I am concerned that those who may have access to the SAS tables in the background may be able to see my password.  In the past I have used the encrypted password, but the Teradata tables that require my password will not accept the encrypted SAS password.  

Is there a way I can be prompted to enter my password and then it is passed to the library assignments that are now in the "submit SAS code when server is connected"
0
Experts,

I have a column DOB which is on TableA   one of the tables I am reading into my Oracle query.  The query has multiple tables.  Can someone tell me how to calculate the age as of Dec 01, 2016.

I am using a pass-through query in SAS to read the Oracle tables.
0
Hey all,
I am trying to get my feet wet in R programming for statistical analysis. '

Can anyone of you, tell me what is the basic differences and similarities between a list and vector, in a simple  layman’s terms…
What is a  data frames?

Thank you
0
Experts,
I know there is a way to find all of the tables in a directory in SAS the contain a certain column using Dictionary.columns

Does anyone know the syntax for this.  I remember doing it a while back, but cannot find the code.

Column = SRC_GRP_NBR
Directory = PROD

Can someone give me the syntax
0
On Demand Webinar: Networking for the Cloud Era
LVL 9
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Hello,
I am trying to simplify the following already working SAS code. Is there way how to do that in easier/sufficient SAS code?  Right now the processing is taking very long time because datasets are large (over million records).  
Any suggestions/comments will be appreciated!

 
/* Creating a record for each combination of the two duplicates */

data data2 data3;
  set data1;
      by var4;
  retain x 0;

  if first.var4 then do;
     x=1;
     output data2;
  end;
  else do;
     x=x+1;
     output data3;
  end;
run;

data data2 data4;
  merge data3(in=a) data2(in=b);
     by var4;

  if (a and b) and x=1 then output data2; /* If primary and duplicate */
  if b and not a then output data4; /* If primary with no duplicate */
run;

data data5 (keep= var4 var1 var2 var3 x); /*Keep needed variables*/
  set data2 data3;
run;

proc sort data=data5; 
  by var4; 
run;

/* Create var1 and var2 from combination of clerical duplicates */
proc sql;
create table data6 as
   select b.var2 as var1, a.var2, a.var3
     from data5 as a, data5 as b   /* Setting a and b */               
     where a.var1=b.var1 and b.x > a.x; /* Select variables with the same combination from*/
quit;                                     /* dataset and where there is a match */
 
/* Set var3=FOX */
proc sql;
  update data6
  set var3='FOX'; 
quit;     

Open in new window

0
First of all thank you for your help in advance. My question is regarding Matlab and non-linear Least Square curve fitting in Matlab - in both I am not familiar with.

I have this type of data:

x = [600, 800, 1000, 1200, 1400]; 
y = [0, 02, 04, 0.7, 1];

Open in new window


I am trying to use the following algorithms:

f = @(p,x) (p(3)-p(4))./(1+exp(-(x-p(2))/p(1)))+p(4); 
opts = optimset('Display','off','MaxFunEvals',1000); 
sigfit = lsqcurvefit(f, starting_value, intervals,problong,[],[],opts); 
bisection_point= sigfit(2)-sigfit(1)*log((sigfit(3)-0.5)/(0.5-sigfit(4)))

Open in new window


The only problem I have is the starting value in sigfit variable. What would be the best starting values given the above numbers? Any help please would be extremely appreciated.

The above algorithms are based on lsqcurvefit function found in Matlab. Here is the link: http://uk.mathworks.com/help/optim/ug/lsqcurvefit.html

The X vector is time intervals in milliseconds, whereas the Y vector represents responses some participant made whether those intervals where perceived as close to a short (400ms) or long (1600ms) interval.

I don't understand what starting points mean. Ultimately what I need to do is find the 0.5 point in the Y axis and the corresponding value on the X axis. The solution will be somewhere between 600ms to 1400 ms and probably around the 1200ms mark. I have put the starting value as a vector from 600 to 1400 but, I have no idea whether that is right or what that means. I was hoping someone better equipped than me can help answer this problem precisely :).

Thank you again,
Dritan
0
Experts,

Can someone tell me how to extract the last character from a text field.  Below is an example of a text fieldA and I would like to extract the last character which in this case is '5'.  Field A can be any length

 Field A = 'BY CHIP, KY R5'
0
I'm looking for a utility or program that will run an analysis on a given disk and provide information about the amount of consumption over time.  Say for example over the last year we've consumed X amount of disk space.

THanks ...

Joel
0
I have a set of data (attached) which shows the volume of web traffic by Country, trended weekly. I'm trying to learn/find a statistical method that help me analyze the data in the following way:

  1. How much does it change? (Max, Min) -- I actually don't need an answer to this, I know how to do it, just reference for the second question below
  2. What is it's normal range? (Normal highs and lows, not maximums/minimums)
  3. What is the trend? (increasing, decreasing)

Are there statistical formulas to help understand this?
0
If you had to pick a place for your SSL encryption to go, what would be the best place to place it and why? At the IIS level.....or at the application level?

We use IIS in conjunction with SAS to serve web pages to our external customers in our current environment. We currently are using SSL encryption via IIS, but are wondering if this is the best configuration or if moving forward it would be better to encrypt the web traffic at the SAS Level.

Let me know if you need any additional info. Thank you!
0
Can you recommend a Cloud Storage provider that is economical if I want to store up to 1 TB ? My files are primarily MP4 type files. I want to share the files with a select group of friends.
0
Experts,

I am able to query a DB2 table from SAS EG using a connection to DB2.
 I can assign a library using:
LIBNAME TST DB2 USER=&USR. PASSWORD=&PWD. DATASRC=&SRC.;

The problem is the lib is assigned but I do not see any tables.
Does anyone know what I need to do and is there a way to do a PROC CONTENTS?

I can query using this syntax:
Proc SQL;
   Connect to db2(db=&SRC. user=&USR.   pass=&PWD.);
         Create table mytst as select * from connection to db2
               (Select * from BM.TABLEA);
   Disconnect from db2;

BM=Schema    Table Name = TABLEA
0
Hi Everyone,

I'm working on a SAS project and we are currently working on setting up the folder directories.  Does anyone know how to change the default SAS temporary work directory?
0
On Demand Webinar: Networking for the Cloud Era
LVL 9
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Experts,

I have a macro that takes multiple rows and puts them into one comma delimited column:
Example:
Code              Color      
  001               Red
  001               Blue
  001               Green
  001               Yellow
Becomes:

001                   Red, Blue, Green, Yellow

Can anyone tell me how I can take a column that is comma delimited and split the values out to a separate rows:
Code  Lit
 001    Red, Blue, Green, Yellow
Becomes:
Code        Color
001           Red
001           Blue
001          Green
001          Yellow

I would like to do this in SAS
0
Experts,

I have a table that has multiple variables that were created in a Proc SQL statement.  I would like to transpose these variables so I have a vertical list instead of a horizontal list.

I saw the %multiTranspose macro online but I cannot figure out exactly how to use it.
I have Filea which has the following variables sum_no_dates , Sum_no_address, Sum_no_zip,  Sum_no_birthdate
Can someone tell me how I can transpose these variables?  If %multiTranspose is not the way can you suggest another method.
Currently I do in manually after exporting to Excel.
0
How to calculate the value or what is the formula in the relative frequency column?  Thanks

screenshot.jpg
0
Hi experts,

I have some problem  having calculating CAGR of my investment ...for example i had invested 10000 Each month for last 15 Years (180 Months) which comes to total investment of 1800000. each month i got some units based on its NAV price. if i sum up all units and multiply with current NAV some total arrived ...i had applied simple CAGR formula i.e. CAGR = ((End value/Start Value)^(1/15))-1....it comes to 14.35% CAGR but actually it is more then what i got it ...as investment is divided evenly with 15 years. what is the formula for calculating CAGR for this type of investment ...actual CAGR is 24.7% i just need to know how its come.

See Attached

Thanks
CAGR-for-SIP-V1.xlsx
0
I ran process monitor from Microsoft Sysinternals tool for only a few minutes I got 54,000 Name not found. 18,000 Reparse. 5,000 File blocked with only readers.

With so many errors where would be the starting point for troubleshooting?
0
Experts,

If I have a macro that looks like this.
%macro(code,lit);
       Proc Sql;
             Create table_&lit as
                      Select  * from Tablea
                            where tableacode = &code;
%mend;

I want the input for the macro to come from FILEB. (Columns code lit)

Is there a way to do this.
0

Statistical Analysis System (SAS)

105

Solutions

120

Contributors

The Statistical Analysis System (SAS) programs consist of two steps, the DATA step and the PROC step. The DATA step reads data and prepares it for use by subsequent DATA or PROC steps. A SAS procedure (PROC) is a collection of statements that execute a certain task. SAS procedures have their own statements and commands, but many are shared among procedures. JMP is the graphical user interface for SAS, and is used in applications such as Six Sigma, quality control and engineering, design of experiments and scientific research.

Top Experts In
Statistical Analysis System (SAS)
<
Monthly
>

No Top Experts for this time period. Answer questions to earn the title!