Skip to content

Instantly share code, notes, and snippets.

@abhishekdagarit
Last active September 22, 2017 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhishekdagarit/2dfa35bf26f8347724873f0eb1ff8f4d to your computer and use it in GitHub Desktop.
Save abhishekdagarit/2dfa35bf26f8347724873f0eb1ff8f4d to your computer and use it in GitHub Desktop.
Printing in SAS

Printing a dataset

proc print data = d1;
run;

Printing only one variable

proc print data = d1;
var a;
run;

Printing observations in SAS

Printing without observations

proc print data = work.test2 noobs;
run;

Defines last observations

proc print data = work.test2(obs=7);
run;

Defines first observation

proc print data = work.test2(obs=7);
run;

Defines first and last observation

proc print data = work.test2(firstobs=3 obs=7);
run;

Defining length of a variable

Alignment needed.Do not use if the data is not aligned.

data test;
input name$1-10 age salary;
datalines;
ak das 23 23432432432;
bk sharma 24 234324234;
ck verma 31 2343290923;
dk gupta 12 2343242;
run;

Here it will not work fine.

Can be used at multiple places
data test;
input name$1-10 age13-14 salary14-18;
datalines;
...
...
...
...
run;

Placement of the numbers doesn't matter. Can be moved around.

data test;
input name$1-10 salary14-15 age 13-14;
datalines;
...
...
...
...
run;

Possible to create another variable from existing variables.

data test;
input name$1-10 firstname$1-5 lastname$6-10 age salary;
datalines;
...
...
...
...
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment